]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
workspace: Don't keep stale clones in list
authorFlorian Müllner <fmuellner@gnome.org>
Mon, 9 Jul 2018 09:50:25 +0000 (11:50 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 9 Jul 2018 11:00:17 +0000 (13:00 +0200)
If a clone gets destroyed before the corresponding MetaWindow is
removed from the workspace, we will still find it in the list of
clones and try to destroy it again. Avoid the resulting warnings
by updating the list of clones immediately when a clone is destroyed.

https://bugzilla.gnome.org/show_bug.cgi?id=791233

js/ui/workspace.js

index d9baef61da91f88af4666741ba3390bf6705de54..06a9d777417ebba351e774c44a46373ce35c5192 100644 (file)
@@ -1443,34 +1443,26 @@ var Workspace = new Lang.Class({
     _doRemoveWindow(metaWin) {
         let win = metaWin.get_compositor_private();
 
-        // find the position of the window in our list
-        let index = this._lookupIndex (metaWin);
-
-        if (index == -1)
-            return;
-
-        let clone = this._windows[index];
-
-        this._windows.splice(index, 1);
-        this._windowOverlays.splice(index, 1);
-
-        // If metaWin.get_compositor_private() returned non-NULL, that
-        // means the window still exists (and is just being moved to
-        // another workspace or something), so set its overviewHint
-        // accordingly. (If it returned NULL, then the window is being
-        // destroyed; we'd like to animate this, but it's too late at
-        // this point.)
-        if (win) {
-            let [stageX, stageY] = clone.actor.get_transformed_position();
-            let [stageWidth, stageHeight] = clone.actor.get_transformed_size();
-            win._overviewHint = {
-                x: stageX,
-                y: stageY,
-                scale: stageWidth / clone.actor.width
-            };
+        let clone = this._removeWindowClone(metaWin);
+
+        if (clone) {
+            // If metaWin.get_compositor_private() returned non-NULL, that
+            // means the window still exists (and is just being moved to
+            // another workspace or something), so set its overviewHint
+            // accordingly. (If it returned NULL, then the window is being
+            // destroyed; we'd like to animate this, but it's too late at
+            // this point.)
+            if (win) {
+                let [stageX, stageY] = clone.actor.get_transformed_position();
+                let [stageWidth, stageHeight] = clone.actor.get_transformed_size();
+                win._overviewHint = {
+                    x: stageX,
+                    y: stageY,
+                    scale: stageWidth / clone.actor.width
+                };
+            }
+            clone.destroy();
         }
-        clone.destroy();
-
 
         // We need to reposition the windows; to avoid shuffling windows
         // around while the user is interacting with the workspace, we delay
@@ -1865,6 +1857,9 @@ var Workspace = new Lang.Class({
         clone.connect('size-changed', () => {
             this._recalculateWindowPositions(WindowPositionFlags.NONE);
         });
+        clone.actor.connect('destroy', () => {
+            this._removeWindowClone(clone.metaWindow);
+        });
 
         this.actor.add_actor(clone.actor);
 
@@ -1886,6 +1881,17 @@ var Workspace = new Lang.Class({
         return [clone, overlay];
     },
 
+    _removeWindowClone(metaWin) {
+        // find the position of the window in our list
+        let index = this._lookupIndex (metaWin);
+
+        if (index == -1)
+            return null;
+
+        this._windowOverlays.splice(index, 1);
+        return this._windows.splice(index, 1).pop();
+    },
+
     _onShowOverlayClose(windowOverlay) {
         for (let i = 0; i < this._windowOverlays.length; i++) {
             let overlay = this._windowOverlays[i];